from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QFrame, QLineEdit, QLabel,
                             QSplitter, QStyleFactory, QApplication, QPushButton)
import sys
from PyQt5 import QtCore

import sqlite3
import subprocess


'ssh -l root -p 22 119.3.194.229'
'ssh -i /root/.ssh/id_rsa root@192.168.1.2'


class ssh_gui(QWidget):
    def __init__(self):
        super().__init__()

        self.initUI()

    def set_head_frame(self, head:QWidget):
        head_layout = QHBoxLayout()
        # lbl = QLabel()
        target = [['服务器：', 'qser'], ['端口:', 'qprt'],
                  ['账号：', 'qusr'], ['密码：', 'qpas']]
        self.head_info = {}
        for i in target:
            lbl = QLabel()
            lbl.setText(i[0])
            self.head_info[i[1]] = QLineEdit(self)
            head_layout.addWidget(lbl)
            head_layout.addWidget(self.head_info[i[1]])

        btn_sure = QPushButton()
        btn_sure.setText("登录")
        # btn_sure.setBaseSize(100,20)
        head_layout.addWidget(btn_sure)

        head.setLayout(head_layout)
        pass


    def initUI(self):
        hbox = QHBoxLayout(self)

        head = QWidget(self)
        self.set_head_frame(head)
        # head.setFrameShape(QWidget)

        dev_info = QFrame(self)
        dev_info.setFrameShape(QFrame.StyledPanel)
        
        cmd_info = QFrame(self)
        cmd_info.setFrameShape(QFrame.StyledPanel)

        left = QFrame(self)
        left.setFrameShape(QFrame.StyledPanel)

        splitter1 = QSplitter(Qt.Vertical)
        splitter1.addWidget(head)
        splitter1.addWidget(dev_info)
        splitter1.addWidget(cmd_info)
        splitter1.setStretchFactor(1,9)

        splitter2 = QSplitter(Qt.Horizontal)
        splitter2.addWidget(left)
        splitter2.addWidget(splitter1)
        splitter2.setStretchFactor(1, 7)

        hbox.addWidget(splitter2)
        self.setLayout(hbox)

        self.setGeometry(0, 0, 600, 480)
        self.setWindowTitle('SSH GUI')
        self.show()

    # def onChanged(self, text):
    #     self.lbl.setText(text)
    #     self.lbl.adjustSize()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = ssh_gui()
    sys.exit(app.exec_())
